//
//  expressXiaoTableViewCell.m
//  A Learning Walk
//
//  Created by dllo on 16/6/16.
//  Copyright © 2016年 战斗民族. All rights reserved.
//

#import "expressXiaoTableViewCell.h"

@implementation expressXiaoTableViewCell


- (void)dealloc {
    [_imageTo release];
    [_labelTitle release];
    [_labelData release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}
-(void)creatCell{
    
    self.imageTo = [[UIImageView alloc] init];
    self.imageTo.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageTo];
    
    self.labelTitle = [[UILabel alloc] init];
    self.labelTitle.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.labelTitle];
    
    self.labelData = [[UILabel alloc] init];
    self.labelData.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.labelData];
    self.labelData.numberOfLines = 0;
    self.labelData.font = [UIFont systemFontOfSize:14];
    
    [self.imageTo release];
    [self.labelData release];
    [self.labelTitle release];
}
-(void)layoutSubviews{
    [super layoutSubviews];

    self.imageTo.frame = CGRectMake(10, 10, 40, 40);
    self.labelTitle.frame = CGRectMake(self.imageTo.frame.size.width+20, 10, self.contentView.frame.size.width/2, 20);
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName,nil];
    CGRect rect = [self.model.content boundingRectWithSize:CGSizeMake(self.contentView.frame.size.width-70, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    
    
    
    self.labelData.frame =CGRectMake(60, self.labelTitle.frame.size.height+self.labelTitle.frame.origin.y+10, self.contentView.frame.size.width-60, rect.size.height);
    self.labelData.text = _model.content;

}
-(void)setModel:(commentlist *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
//    NSLog(@"***%@",_model);
    
    [self.imageTo sd_setImageWithURL:[NSURL URLWithString:_model.headimg]];
    self.labelTitle.text = _model.username;
    self.labelData.text = _model.content;
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


@end
